﻿using System;
using System.Numerics;

class VariousMethods
{
    //Exercise 14.
    //Write methods to calculate minimum, maximum, average, sum and product of given set of integer numbers. 
    //Use variable number of arguments.

    static void Main()
    {
        //initialize the array fo integers
        Console.Write("Length of the array = ");
        int size = int.Parse(Console.ReadLine());
        int[] array = new int[size];
        Random random = new Random();
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = random.Next(0, 100);
            Console.Write(array[i] + " ");
        }
        Console.WriteLine();
        Console.WriteLine();

        int minimum = Minimum(array);
        Console.WriteLine("The minimum is: {0}", minimum);

        int maximum = Maximum(array);
        Console.WriteLine("The maximum is: {0}", maximum);

        int sum = Sum(array);
        Console.WriteLine("The sum is: {0}", sum);

        double average = (double)sum / (double)size;
        Console.WriteLine("The average is: {0:0.00}", average);

        BigInteger product = Product(array);
        Console.WriteLine("The product is: {0}", product);
    }

    private static BigInteger Product(int[] array)
    {
        BigInteger product = 1;
        for (int i = 0; i < array.Length; i++)
        {
            product = product * array[i];
        }
        return product;
    }

    private static int Sum(int[] array)
    {
        int sum = 0;
        for (int i = 0; i < array.Length; i++)
        {
            sum = sum + array[i];
        }
        return sum;
    }

    private static int Maximum(int[] array)
    {
        int maximum = int.MinValue;
        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] > maximum)
            {
                maximum = array[i];
            }
        }
        return maximum;
    }

    private static int Minimum(int[] array)
    {
        int minimum = int.MaxValue;
        for (int i = 0; i < array.Length; i++)
        {
            if (array[i] < minimum)
            {
                minimum = array[i];
            }
        }
        return minimum;
    }
}

